package com.fsl.springbootdesignpattern.a_singleton;

/**
 * @author sj2
 * 这种方式采用双锁机制，安全且在多线程情况下能保持高性能。
 */
public class SingletonD {

    private SingletonD(){}

    private volatile static SingletonD singletonD;

    private static SingletonD getSingletonD(){
        if(singletonD==null){
            synchronized (SingletonD.class){
                if(singletonD==null){
                    singletonD = new SingletonD();
                }
            }
        }
        return singletonD;
    }

}
